home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr05 / shwdib.zip / DLGOPENA.ASM < prev    next >
Assembly Source File  |  1993-07-26  |  3KB  |  109 lines

  1.     title    dlgopena.asm
  2. ;*******************************************************************************
  3. ;*                                           *
  4. ;*  MODULE    : DLGOPENA.ASM                               *
  5. ;*                                           *
  6. ;*  DESCRIPTION : Assembly language helper routines for DLGOPEN.C           *
  7. ;*                                           *
  8. ;*  FUNCTIONS    : chdir ()  - change to specified asciiz directory.           *
  9. ;*                                           *
  10. ;*******************************************************************************
  11. ?WIN = 1
  12.  
  13. ?PLM=1        ; PASCAL Calling convention is DEFAULT
  14. ?WIN=1        ; Windows calling convention
  15. ?386=0        ; Use 386 code?
  16. include cmacros.inc
  17.  
  18. ;*********************************************************************
  19. ;* The following structure should be used to access high and low
  20. ;* words of a DWORD.  This means that "word ptr foo[2]" -> "foo.hi".
  21. ;*********************************************************************
  22.  
  23. LONG    struc
  24. lo      dw      ?
  25. hi      dw      ?
  26. LONG    ends
  27.  
  28. FARPOINTER      struc
  29. off     dw      ?
  30. sel     dw      ?
  31. FARPOINTER      ends
  32.  
  33. ;*********************************************************************
  34. ;               DATA SEGMENT DECLARATIONS
  35. ;*********************************************************************
  36.  
  37. ifndef SEGNAME
  38.     SEGNAME equ <TEXT>
  39. endif
  40.  
  41. if ?386
  42.     .386p
  43.     createSeg _%SEGNAME, CodeSeg, word, use16, CODE
  44. else
  45.     .286p
  46.     createSeg _%SEGNAME, CodeSeg, word, public, CODE
  47. endif
  48.  
  49. sBegin    DATA
  50. sEnd    DATA
  51.  
  52. sBegin    CodeSeg
  53.  
  54. assumes CS,CodeSeg
  55. assumes DS,DATA
  56.  
  57. ;****************************************************************************
  58. ;*                                        *
  59. ;*  FUNCTION   : chdir (p)                            *
  60. ;*                                        *
  61. ;*  PURPOSE    : Change to asciiz directory specified in p            *
  62. ;*                                        *
  63. ;*  RETURNS    : 1 - Success                            *
  64. ;*         0 - Error                            *
  65. ;*                                        *
  66. ;****************************************************************************
  67.  
  68. cProc    chdir,<PUBLIC,FAR,PASCAL>,<ds>
  69.     parmD p
  70. cBegin
  71.     lds    dx,p
  72.     mov    bx,dx
  73.  
  74.     cmp    BYTE PTR ds:[bx+1],':'
  75.         jnz     chdnod                  ; No drive
  76.         mov     dl,ds:[bx]
  77.         or      dl,20h
  78.         sub     dl,'a'
  79.  
  80.     mov    ah,0eh            ; Set current drive
  81.     int    21h
  82.  
  83.     mov    ah,19h            ; Get current drive
  84.     int    21h
  85.  
  86.     cmp    al,dl
  87.     jne    chderror
  88.  
  89.     lds    dx,p
  90.     add    dx,2
  91.     mov    bx,dx
  92.     cmp    BYTE PTR ds:[bx],0    ; If path name is "" we are there
  93.     jz    chdok
  94. chdnod:
  95.     mov    ah,3bh
  96.     int    21h
  97.     jc    chderror
  98. chdok:
  99.     mov    ax,1
  100. chdexit:
  101. cEnd
  102. chderror:
  103.     xor    ax,ax
  104.     jmp    short chdexit
  105.  
  106. sEnd    CodeSeg
  107.  
  108. end
  109.